/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package liceo;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;


/**
  @author kndidox
 */
public class tecladoControlador extends KeyAdapter{
    panelAl aux;

    tecladoControlador(panelAl g){
        aux = g;
    }


    public void keyReleased(KeyEvent e){
        char c = e.getKeyChar();
        boolean resultado;
        System.out.println(c);
        System.out.println(aux.nomText);
        System.out.println( e.getSource() );
        if(e.getSource().equals(aux.nomText))
            System.out.println("Nombre alumno!");
        resultado = esValido(c);
        if(!resultado){
            String cadena = aux.getnomText();
            String nuevaCadena = cadena.replace(c, '\0');
            System.out.println(nuevaCadena);
            aux.setnomText(null);
            aux.setnomText(nuevaCadena);

        }

    }





    public boolean esValido(Character caracter){
        char c = caracter.charValue();
        if ( !(Character.isLetter(c) || c == ' '|| c == 8 ) ){
            System.out.println("No se vale!!!");
            return false;
        }
        else{
            System.out.println("Si se vale!!!");
            return true;
        }
    }

}